import {BaseModel} from "../BaseModel";

export class UserResource extends BaseModel{

    constructor(){
        super();
        this.symbolName = "UserResource";
        this.tableName = "t_user_resource";
        this.id = -1;//主键id，自动递增的int值
        this.userId = '';//用户id
        this.bookId = '';//书本id
        this.lessonId = '';//课程id
        this.resourceClassify = '';//资源分类：0-自己导入的资源；1-云资源库的资源；2-课程本身的资源
        this.resourceType = '';//资源的类型：保利威视、热力图等
        this.resourceId = '';//资源的唯一标识id
        this.resourceName = '';//资源名称
        this.resourceDescription = '';//资源的bsr描述
        this.downloadStatus = '';//下载状态：0-下载成功；1-下载失败；2-未下载
        this.sortIndex = -1;//资源排序的索引：用于正序排列
        this.isDefault = '';//是否默认的ppt：0-不是；1-是
        this.reverse1 = '';//备用字段1 //个人资源课程关系id
        this.reverse2 = '';//备用字段2 //fileId 个人资源文件id
        this.reverse3 = '';//备用字段3  0-上传云端 ；1-未上传云端
    }

    dbMapper(){
        return {
            id: 'id',
            userId: 'user_id',
            bookId: 'book_id',
            lessonId: 'lesson_id',
            resourceClassify: 'resource_classify',
            resourceType: 'resource_type',
            resourceId: 'resource_id',
            resourceName: 'resource_name',
            resourceDescription: 'resource_description',
            downloadStatus: 'download_status',
            sortIndex: 'sort_index',
            isDefault: 'is_default',
            reverse1: 'reverse1',
            reverse2: 'reverse2',
            reverse3: 'reverse3'
        }
    }

    /**
     * 输出转换
     * @param obj
     * @returns {Book}
     */
    mappingModel(obj){
        let userResource = new UserResource();
        userResource.id = obj.id ? obj.id : ''
        userResource.userId = obj.user_id ? obj.user_id : ''
        userResource.bookId = obj.book_id ? obj.book_id : ''
        userResource.lessonId = obj.lesson_id ? obj.lesson_id : ''
        userResource.resourceClassify = obj.resource_classify ? obj.resource_classify : ''
        userResource.resourceType = obj.resource_type ? obj.resource_type : ''
        userResource.resourceId = obj.resource_id ? obj.resource_id : ''
        userResource.resourceName = obj.resource_name ? obj.resource_name : ''
        userResource.resourceDescription = obj.resource_description ? obj.resource_description : ''
        userResource.downloadStatus = obj.download_status ? obj.download_status : ''
        userResource.sortIndex = obj.sort_index ? obj.sort_index : -1
        userResource.isDefault = obj.is_default ? obj.is_default : ''
        userResource.reverse1 = obj.reverse1 ? obj.reverse1 : ''
        userResource.reverse2 = obj.reverse2 ? obj.reverse2 : ''
        userResource.reverse3 = obj.reverse3 ? obj.reverse3 : ''
        return userResource;
    }

}
